package cn.dy.web;

import java.beans.PropertyDescriptor;
import java.util.Date;
import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import cn.dy.entity.main.Flow;
import cn.dy.entity.sub.MsFlow;
import cn.dy.modle.FlowManager;
import cn.dy.modle.MysqlFlowManager;
import cn.dy.vo.FlowVO;

import com.opensymphony.xwork2.ActionSupport;

public class FlowAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Autowired
	private FlowManager flowManager;
	
	@Autowired
	private MysqlFlowManager mysqlFlowManager;
	
	@Override
    public String execute() 
    {
		System.out.println("------------------");
		
		List<Flow> list = flowManager.getAll();
		
		System.out.println(list.size());
//		MsFlow f = new MsFlow();
//		System.out.println(3);
//		f.setCode("123");
//		f.setName("name");
//		f.setCanceled("n");
//		f.setObject("o");
//		f.setLogInst(1);
//		f.setUserSign(1);
//		f.setTransfered("1");
//		f.setCreateDate(new Date());
//		f.setCreateTime(123);
//		f.setUpdateDate(new Date());
//		f.setCreateTime(123);
//		f.setDataSource("1");
//		f.setU_DocType("1");
//		f.setU_Memo("1");
//		f.setU_PrcType("1");
//		f.setU_Type("1");
//		f.setDocEntry(1);
//		System.out.println(4);
//		try{
//			mysqlFlowManager.save(f);
//		}catch(Exception e){
//			e.printStackTrace();
//		}
		int i=0;
		
		try{
		for(Flow ff:list){
			MsFlow msFlow = new MsFlow();
			BeanUtils.copyProperties(ff, msFlow);
			mysqlFlowManager.save(msFlow);
		}
		}catch(Exception e){
			e.printStackTrace();
		}
		System.out.println("------------------");
		return SUCCESS;
    }
	

}
